package com.wee.cronos.client.core.view;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Widget;
import com.gwtplatform.mvp.client.ViewImpl;
import com.wee.cronos.client.core.presenter.ProjectManagementPresenter;
import com.wee.cronos.client.core.presenter.ProjectManagementPresenter.ProjectManagementView;

public class ProjectManagementViewImpl extends ViewImpl implements ProjectManagementView 
{
	interface ProjectManagementUiBinder extends UiBinder<Widget, ProjectManagementViewImpl> {}
	
	protected static final ProjectManagementUiBinder uiBinder = GWT.create(ProjectManagementUiBinder.class);
	
	public Widget widget;
	
	@UiField
	FlowPanel projectManagementPanel;
	
	@UiField
	FlowPanel projectExplorer;
	
	@UiField
	FlowPanel folderExplorer;
	
	public ProjectManagementViewImpl()
	{
	    widget = uiBinder.createAndBindUi(this);
	}
	
	@Override
	public Widget asWidget() 
	{
		return widget;
	}
	
	@Override
	public void setInSlot(Object slot, Widget content) 
	{
		if (slot == ProjectManagementPresenter.TYPE_RevealFolderExplorer) 
		{
			setFolderExplorer(content);
	    }
		else if (slot == ProjectManagementPresenter.TYPE_RevealProjectExplorer)
		{
			setProjectExplorer(content);
		}
		else 
	    {
	    	super.setInSlot(slot, content);
	    }
	}
	
	public void setFolderExplorer(Widget content)
	{
		folderExplorer.clear();
		
		if(folderExplorer != null)
		{
			folderExplorer.add(content);
		}
	}
	
	public void setProjectExplorer(Widget content)
	{
		projectExplorer.clear();
		
		if(projectExplorer != null)
		{
			projectExplorer.add(content);
		}
	}
}